CentOS 7
Sponsored Link

Add Mail Accounts#2
2017/06/28
 
Add Mail User Accounts to use Mail Service.
This example is for the case you use virtual mail-user accounts, not use OS accounts.
[1]
[2] Configure additional settings to Postfix and Dovecot.
# create a admin user for virtual mailboxes

[root@mail ~]#
useradd -u 20000 -s /sbin/nologin vmail
[root@mail ~]#
vi /etc/postfix/main.cf
# line 164: comment out

#
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
# add to the end

# if specify multiple domains, specify comma or space separated
virtual_mailbox_domains = srv.world, virtual.host
virtual_mailbox_base = /home/vmail
virtual_mailbox_maps = hash:/etc/postfix/virtual-mailbox
virtual_uid_maps = static:20000
virtual_gid_maps = static:20000

[root@mail ~]#
vi /etc/dovecot/conf.d/10-auth.conf
# line 100: add

auth_mechanisms =
cram-md5
plain login
# line 125: uncomment

!include auth-passwdfile.conf.ext
# line 128: uncomment

!include auth-static.conf.ext
[root@mail ~]#
vi /etc/dovecot/conf.d/auth-passwdfile.conf.ext
# line 8: change

passdb {
  driver = passwd-file
  args = scheme=CRAM-MD5 username_format=%u /etc/dovecot/users

# line 13: add

userdb {
  driver = passwd-file
  args = scheme=CRAM-MD5 username_format=%u /etc/dovecot/users

[root@mail ~]#
vi /etc/dovecot/conf.d/auth-static.conf.ext
# line 21-24: uncomment and change

userdb {
  driver = static
  args = uid=vmail gid=vmail home=/home/vmail/%d/%n
}

[root@mail ~]#
vi /etc/dovecot/conf.d/10-mail.conf
# line 30: change

mail_location = maildir:
/home/vmail/%d/%n/Maildir
[root@mail ~]#
systemctl restart postfix dovecot
[3] Add virtual mail user accounts.
[root@mail ~]#
vi /etc/postfix/virtual-mailbox
# create new

# [user account] [mailbox]

cent@srv.world   srv.world/cent/Maildir/
ubuntu@srv.world   srv.world/ubuntu/Maildir/
redhat@virtual.host   virtual.host/redhat/Maildir/

[root@mail ~]#
postmap /etc/postfix/virtual-mailbox
# generate password

[root@mail ~]#
doveadm pw

Enter new password:
Retype new password:
{CRAM-MD5}9186d855e11eba527a7a52ca82b313e180d62234f0acc9051b527243d41e2740
[root@mail ~]#
vi /etc/dovecot/users
# create new

# [user account] [password]

cent@srv.world:{CRAM-MD5}9186d855e11eba527a7a52ca82b313e180d62234f0acc9051b527243d41e2740
ubuntu@srv.world:{CRAM-MD5}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
redhat@virtual.host:{CRAM-MD5}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[4]
It's OK. Try to test to send emails on Mail client.
For this settings, specify email address for [Username] on Email Client settings.

 
Tweet